<? include ("../init.php") ?>
<? include ("../header.php") ?>
<? include ("../menu.php") ?>
<? include ("submenu.php") ?>
<?php

  $product_set_id = $_GET['aid'];

  $sql = "SELECT * FROM product_set WHERE product_set_id = '".$product_set_id."'";
  $line = $db->queryUniqueObject($sql);
  
  $sql = 'SELECT * FROM product_cat ORDER BY product_cat_name';
  $rss = $db->query($sql);
  $select_cat = '<select name = "catalogue" class = "input size1" >';
  while ($line2 = $db->fetchNextObject($rss)){
    if($line2->product_cat_id==$line->product_cat_id){
      $selected = 'selected="selected"';
    }else{
      $selected = '';
    }
    $select_cat .= "<option ".$selected." value = '".$line2->product_cat_id."'>".$line2->product_cat_name."</option>";
  }
  $select_cat .= "</select>";
?>
<div id = "body">

<h1><?_l('edit')?> <?_l('product-set')?></h1>

<div class = "clear"></div>

<form method="post" action="update_set.php" class = "form" enctype="multipart/form-data">
  <input name="product_set_id" type="hidden" value="<?=$product_set_id?>"/>
  <input name="old_img" type="hidden" value="<?=$line->product_set_img?>" />
  
  <div class = "field"><label><?_l('catalogue')?></label><?php echo $select_cat; ?></div>
  <div class = "field"><label><?_l('name')?></label><input type = "text" name = "name" class = "input size1" value="<?=$line->product_set_name?>" ></div>
  <div class = "field"><label><?_l('image')?></label><input type = "file" name = "product_set_img" class = "input size1" ></div>
  <?php
    if($line->product_set_img!='' && file_exists('../../images/products/set/'.$product_set_id.'/'.$line->product_set_img)){
      echo '<div class = "field"><label>&nbsp;</label><img src="../../images/products/set/'.$product_set_id.'/'.$line->product_set_img.'" /></div>';
    }
  ?>
  <br />
  <div class = "field"><label></label>
    <input type="submit" name="save" value = "<?_l('update')?>" class = "btn" />
    <input onclick = "javascript:history.back(1)" type = "button" value="<?_l('cancel')?>" class = "btn" />
  </div>
  
  <div class = "clear"></div>
</form>

</div>


<style>
  .form label {
    width:80px;
  }
</style>
<? include ("../footer.php") ?>